package se.hiq.wineo.client.widgets.common;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;


/**
 * Widget for presenting a Label and its corresponding Value. Neither is editable by the user
 * 
 * @author joakimsah
 *
 */
public class ValueWidget extends Composite {

	// Widgets in this Composite
	private Grid mainPanel;
	private Label nameLabel;
	private Label valueLabel;
	
	public ValueWidget(String name, String value) {
		mainPanel = new Grid(1, 2);
		nameLabel = new Label(name);
		nameLabel.setStyleName("value-widget-name");
		valueLabel = new Label(value);
		valueLabel.setStyleName("value-widget-value");
		
		mainPanel.setWidget(0, 0, nameLabel);
		mainPanel.setWidget(0, 1, valueLabel);
		initWidget(mainPanel);
	}
	
	/**
	 * Update the value shown
	 * 
	 * @param value
	 */
	public void setValue(String value) {
		valueLabel.setText(value);
	}
		
}
